package com.ruoyi.config

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.Fail
import org.pac4j.core.exception.http.ForbiddenAction
import org.pac4j.core.exception.http.HttpAction
import org.pac4j.core.exception.http.UnauthorizedAction
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.ResponseBody

@ControllerAdvice
class GlobalFlyExceptionHandler {


    @ExceptionHandler(value = [HttpAction::class])
    @ResponseBody
    fun bizExceptionHandler(e: HttpAction): Data<Any>? = Fail(e.code, e.localizedMessage)
}
